def quick_sort(alist):
    if len(alist) <=1:
        return alist
    middle = alist[len(alist)//2]
    right = [x for x in alist if x < middle]
    left = [x for x in alist if x > middle]
    return quick_sort(right) + [middle] + quick_sort(left)

print(quick_sort([5,4,3,2,1]))
